<template>
  <div>
    <h2>Count组件当前和为：{{ sum }}</h2>
    <h2>当前和放大10倍：{{ bigSum }}</h2>
    <h2>我是{{ name }},今年{{ age }}</h2>
    <h3 style="color:green">person列表总人数是：{{personList.length}}</h3>
    <select v-model.number="n">
      <option :value="1">1</option>
      <option :value="2">2</option>
      <option :value="3">3</option>
    </select>
    <button @click="increment(n)">++</button>
    <button @click="decrement(n)">--</button>
    <button @click="incrementOdd(n)">当前和为奇数再加</button>
    <button @click="decrementOdd(n)">等2秒再加</button>
  </div>
</template>

<script>
import { mapGetters, mapState, mapMutations, mapActions } from "vuex";
export default {
  name: "Count",
  data() {
    return {
      n: 1,
    };
  },
  computed: {
    ...mapState(["sum", "name", "age", "personList"]),

    ...mapGetters(["bigSum"]),
  },
  methods: {
   
    ...mapMutations({ increment: "PLUS", decrement: "REDUCE" }),
   
    ...mapMutations(["PLUS", "REDUCE"]),

    ...mapActions({ incrementOdd: "plusOdd", decrementOdd: "plusWait" }),
   
    ...mapActions(["plusOdd", "plusWait"]),
  },
  mounted() {},
};
</script>

<style lang="css">
button {
  margin-left: 5px;
}
</style>